<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <meta name="apple-mobile-web-app-capable" content="yes" />

        <!-- Base Css Files -->
        <link href="/ouju/Public/statics/coco-chat/assets/libs/jqueryui/ui-lightness/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/fontello/css/fontello.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/animate-css/animate.min.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/nifty-modal/css/component.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/magnific-popup/magnific-popup.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/css/style.css" rel="stylesheet" type="text/css" />
        <link href="/ouju/Public/statics/coco-chat/assets/css/style-responsive.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/pace/pace.css" rel="stylesheet" />
        <link href="/ouju/Public/statics/coco-chat/assets/libs/jquery-notifyjs/styles/metro/notify-metro.css" rel="stylesheet" type="text/css" />

        <!-- Extra CSS Files -->
      	<link href="/ouju/Public/statics/coco-chat/assets/libs/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" type="text/css" />

        <!-- Custom Css Files -->
        <link href="/ouju/tpl/Admin/Public/css/style.css"  rel="stylesheet" />
    </head>

    <body>
	<!-- Begin page -->
	<div>
        <div class="sub-header-title">
            <h2>充值记录</h2>
        </div>
        <form method="post" class="form-horizontal" action="<?php echo U('Cash/payList');?>">
       		<div class="form-group">
	         	<div class="col-sm-2">
	                <select class="form-control selectpicker" name="status">
		              		<option value="-1">全部状态</option>
		              		<option value="0" <?php if($status == '0'): ?>selected<?php endif; ?>>等待支付</option>
		              		<option value="1" <?php if($status == '1'): ?>selected<?php endif; ?>>支付成功</option>
		              		<option value="2" <?php if($status == '2'): ?>selected<?php endif; ?>>已关闭</option>
		            </select>
	            </div>
	  			<div class="col-sm-2">
	        		<div class="input-group">
                     	<span class="input-group-addon">日期</span>
                     	<input type="text" class="form-control" id="date-start" name="start_date" value="<?php echo ($start_date); ?>" placeholder="开始日期"/>
                 	</div>
	           	</div>
	          	<div class="col-sm-2">
             		<div class="input-group">
	                    <span class="input-group-addon">-</span>
	                  	<input type="text" class="form-control" id="data-end" name="end_date" value="<?php echo ($end_date); ?>" placeholder="截止日期"/>
	              	</div>
	       		</div>
	       		<div class="col-sm-2">
	               	<input class="form-control" placeholder="根据订单号/会员编号搜索" value="<?php echo ($keyword); ?>" name="keyword" type="text">
	            </div>
	            <div class="col-sm-2">
	                <button class="btn btn-success" type="submit">查询</button>
	            </div>
	        </div>
        </form>
    </div>

    <div class="widget">
        <div class="widget-content">
        	<h4 class="form-group">
        		已充值总计:<span class="total">￥<?php if($statistics["sum_total"] == 0): ?>0.00<?php else: echo ($statistics["sum_total"]); endif; ?></span>
        	</h4>
           	<table class="table table-bordered table-striped">
                <thead>
                    <tr>
                    	<th>会员编号</th>
                    	<th>交易信息</th>
                    	<th>充值金额</th>
                        <th>支付状态</th>
                        <th>充值描述</th>
                        <th>时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                	<?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
	                    	<td><?php echo ($vo["user_no"]); ?></td>
                      		<td>
                      			订单号：<?php echo ($vo["order_no"]); ?><br/>
                            <?php if($vo["trade_no"] != ''): ?>交易流水号:<?php echo ($vo["trade_no"]); ?><br/><?php endif; ?>
                      		</td>
                      		<td>￥<?php echo ($vo["amount"]); ?></td>
	                        <td>
	                        	<?php switch($vo["status"]): case "0": ?>等待支付<?php break;?>
							        <?php case "1": ?>支付成功<?php break;?>
							        <?php case "2": ?>已关闭<?php break;?>
							        <?php default: ?>未知<?php endswitch;?>
	                        </td>
	                        <td><?php echo ($vo["title"]); ?></td>
	                        <td>
	                        	创建时间：<?php echo ($vo["add_time"]); ?><br/>
								            <?php if($vo["success_time"] > 0): ?>支付成功时间：<?php echo ($vo["success_time"]); ?><br/><?php endif; ?>
            							</td>
            							<td ref="<?php echo ($vo["order_no"]); ?>">
	                        	<?php if($vo['status'] == 0): ?><a class="payment_query" href="javascript:;">支付结果查询</a><br />
                              <a class="order_cancel" href="javascript:;">取消</a>
                            <?php else: ?> -<?php endif; ?>
							             </td>
	                 	</tr><?php endforeach; endif; else: echo "" ;endif; ?>
            	</tbody>
            </table>
            <?php echo ($page); ?>
        </div>
    </div>
    <!-- End of page -->

	<!-- Base Js Files -->
	<script src="/ouju/Public/statics/coco-chat/assets/libs/jquery/jquery-1.11.1.min.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/bootstrap/js/bootstrap.min.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/jqueryui/jquery-ui-1.10.4.custom.min.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/jquery-ui-touch/jquery.ui.touch-punch.min.js"></script>
 	<script src="/ouju/Public/statics/coco-chat/assets/libs/jquery-detectmobile/detect.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/fastclick/fastclick.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/jquery-slimscroll/jquery.slimscroll.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/nifty-modal/js/classie.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/nifty-modal/js/modalEffects.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/jquery-notifyjs/notify.min.js"></script>
    <script src="/ouju/Public/statics/coco-chat/assets/libs/jquery-notifyjs/styles/metro/notify-metro-blue.js"></script>
	<script src="/ouju/Public/statics/coco-chat/assets/libs/pace/pace.min.js"></script>

	<!-- Extra Js Files -->
	<script src="/ouju/Public/statics/coco-chat/assets/libs/bootstrap-select/bootstrap-select.min.js"></script>
    <script src="/ouju/Public/statics/coco-chat/assets/libs/bootstrap-select2/select2.min.js"></script>
    <script src="/ouju/Public/statics/coco-chat/assets/libs/laydate/laydate.js"></script>

	<!-- Custom Js Files -->
	<script src="/ouju/tpl/Admin/Public/js/common.js"></script>

    <script>
    	var start = {
   		  	elem: '#date-start', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
   		 	event: 'focus', //响应事件。如果没有传入event，则按照默认的click
   		 	max: laydate.now(), //最大日期
   		  	choose: function(datas){
   		     	end.min = datas; //开始日选好后，重置结束日的最小日期
   		     	end.start = datas //将结束日的初始值设定为开始日
   		  	}
   		};
   		var end = {
   		  	elem: '#data-end', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
   		 	event: 'focus', //响应事件。如果没有传入event，则按照默认的click
   		 	max: laydate.now(), //最大日期
   		  	choose: function(datas){
   		    	start.max = datas; //结束日选好后，重置开始日的最大日期
   		  	}
   		};
   		laydate(start);
   		laydate(end);

   		//SELECT
		$('.selectpicker').selectpicker();

		//绑定支付查询事件
		$(".payment_query").click(function(event) {
	    	var order_no = $(this).parent('td').attr("ref");

			// 用ajax提交表单
	      	$.post("<?php echo U('Cash/paymentQuery');?>", "order_no="+order_no, function(response) {
	      		//弹出提示
				window.parent.layer.msg(response.message);

	      		//根据请求相应状态提示通知
	       		if(response.status){
	       			notify("success",response.message);
					window.location.reload();
				}else{
					notify("error",response.message);
				}
	        }, 'json');
	    });
    $(".order_cancel").click(function(event){
      var order_no = $(this).parent('td').attr("ref");
      $.post("<?php echo U('Cash/orderCancel');?>",{order_no:order_no}, function(response){
        //弹出提示
        window.parent.layer.msg(response.message);

        //根据请求相应状态提示通知
        if(response.status){
          notify("success",response.message);
          window.location.reload();
        }else{
          notify("error",response.message);
        }
      }, 'json');
    });
	</script>
	</body>
</html>